﻿using System;
using System.Globalization;
using System.Windows.Controls;
using RicSal.BusinessLogic.NationalIdNumber;

namespace Mari.SmartHotel.Controls.ValidationRules
{
    public class FiscalCodeValidationRule : ValidationRule
    {
        public override ValidationResult Validate(object value, CultureInfo cultureInfo)
        {
            try
            {
                NationalIdNumberFactory.Create(cultureInfo.TwoLetterISOLanguageName).Validate((string)value);
                return ValidationResult.ValidResult;
            }
            catch (Exception ex)
            {
                return new ValidationResult(false, ex.Message);
            }
        }
    }
}
